package org.nightrunner.d3.service.impl;

import java.io.Serializable;
import java.util.List;

import org.nightrunner.d3.dao.IPropertyDao;
import org.nightrunner.d3.entity.Property;
import org.nightrunner.d3.model.DefaultPaginationInfo;
import org.nightrunner.d3.model.IPaginationInfo;
import org.nightrunner.d3.model.PaginationModel;
import org.nightrunner.d3.service.IPropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Property Service implementation
 * 
 * @author NigthRunner
 * @date 2012-7-26
 * @version 1.0
 */

@Service
public class PropertyService implements IPropertyService {

	@Autowired
	private IPropertyDao propertyDao;

	public IPropertyDao getPropertyDao() {
		return propertyDao;
	}

	public void setPropertyDao(IPropertyDao propertyDao) {
		this.propertyDao = propertyDao;
	}

	public Serializable addProperty(Property property) {
		return propertyDao.save(property);
	}

	public Property getProperty(String bureauId) {
		return propertyDao.get(bureauId);
	}

	public List<Property> getAllProperty() {
		return propertyDao.list();
	}

	public void deleteProperty(Property property) {
		propertyDao.delete(property);
	}

	public PaginationModel<List<Property>> getProperty() {
		IPaginationInfo paginationInfo = new DefaultPaginationInfo();
		paginationInfo.setCurrentPage(0);
		paginationInfo.setRowSize(10);
		return getPropertys(paginationInfo);
	}

	public PaginationModel<List<Property>> getPropertys(
			IPaginationInfo pagination) {
		return propertyDao.find(pagination);
	}

	public void updateProperty(Property property) {
		propertyDao.merge(property);
	}
}
